﻿Public Class frmRevertirPago
    Public Usuario, Cliente, CodCliente As String
    Public Monto As Double
    Public NumFactura, NumCuota, IdDetallePago As Integer

    Private Sub btnRevertir_Click(sender As Object, e As EventArgs) Handles btnRevertir.Click
        If Me.txtMotivo.EditValue <> Nothing Then
            Revertir()
        Else
            Me.txtMotivo.BackColor = Color.LemonChiffon
            MessageBox.Show("Ingrese el motivo de la reversión.", varTitulo, MessageBoxButtons.OK, MessageBoxIcon.Asterisk)
            Me.txtMotivo.Focus()
        End If
    End Sub

    Private Sub Revertir()
        Try
            Me.DetallePlanPagoTableAdapter1.SP_RevertirPago(IdDetallePago)

            MessageBox.Show("Se ha revertido el pago correctamente.", varTitulo, MessageBoxButtons.OK, MessageBoxIcon.Information)
            frmControlCreditosVigentes.ActualizarGrilla()

            Me.Log_ReversionesTableAdapter.Insert(Usuario, Date.Now, Me.txtMotivo.EditValue, Monto, CodCliente, Cliente, NumFactura, NumCuota)

            Me.Dispose()
            Me.Close()
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub

    Private Sub txtMotivo_EditValueChanged(sender As Object, e As EventArgs) Handles txtMotivo.EditValueChanged
        Me.txtMotivo.BackColor = Color.White
    End Sub
End Class